unit UnitCadPerfil;

interface

uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, UnitCadModelo, Grids, DBGrids, SMDBGrid, ComCtrls, StdCtrls,
  Mask, DBCtrls, ExtCtrls, Buttons, db, jpeg;

type
  TFormCadPerfil = class(TFormCadModelo)
    DBEdit2: TDBEdit;
    TabSheet1: TTabSheet;
    SMDBGrid4: TSMDBGrid;
    SMDBGrid1: TSMDBGrid;
    Splitter1: TSplitter;
    procedure btOKClick(Sender: TObject);
    procedure FormClose(Sender: TObject; var Action: TCloseAction);
    procedure SMDBGrid4Enter(Sender: TObject);
    procedure SMDBGrid4Exit(Sender: TObject);
    procedure btCancelarClick(Sender: TObject);
  private
    { Private declarations }
  public
    { Public declarations }
  end;

var
  FormCadPerfil: TFormCadPerfil;

implementation

uses UnitPerfil;

{$R *.dfm}

procedure TFormCadPerfil.btOKClick(Sender: TObject);
begin
  inherited;
  with FormPerfil do
  begin
    if qryDados.State in [dsInsert,dsEdit] then
      qryDados.Post;
    if qryMenu.State in [dsInsert,dsEdit] then
      qryMenu.Post;
    if qrySubMenu.State in [dsInsert,dsEdit] then
      qrySubMenu.Post;
  end;
end;

procedure TFormCadPerfil.FormClose(Sender: TObject;
  var Action: TCloseAction);
begin
  inherited;
  FormCadPerfil := nil;
end;

procedure TFormCadPerfil.SMDBGrid4Enter(Sender: TObject);
begin
  inherited;
  FormPerfil.qrySubmenu.Close;
  FormPerfil.qrySubmenuInterna.LookupCache := True;
  FormPerfil.qrySubmenu.Open;
end;

procedure TFormCadPerfil.SMDBGrid4Exit(Sender: TObject);
begin
  inherited;
  FormPerfil.qrySubmenu.Close;
  FormPerfil.qrySubmenuInterna.LookupCache := False;
  FormPerfil.qrySubmenu.Open;
end;

procedure TFormCadPerfil.btCancelarClick(Sender: TObject);
begin
  inherited;
  with FormPerfil do
  begin
    if qryMenu.State in [dsInsert,dsEdit] then
      qryMenu.Cancel;
    if qrySubMenu.State in [dsInsert,dsEdit] then
      qrySubMenu.Cancel;
    if qryDados.State in [dsInsert,dsEdit] then
      qryDados.Cancel;
  end;
end;

end.
